<?php

namespace App\Admin\SDK\IBay;

// ibay SDK by Martin
class Order extends Core{



    /**
     *  获取订单列表
     *
     * @param $dayStart date   >= 2021-01-01
     * @param $dayEnd date < 2021-02-01
     * @param $timeType string  e.g: created
     * @param $orderstatus string   e.g: '7'
     *
     * @url  /listOrders/dayStart/2021-01-01/dayEnd/2021-02-01/timeType/created
     */
    public function listOrders($dayStart, $dayEnd, $timeType='created', $orderstatus=null):bool
    {
        $url =  $this->url.'/listOrders';
        $url .=  '/auth/'.config("ibay.api")['code'];
        $url .=  '/dayStart/'.$dayStart.'/dayEnd/'.$dayEnd.'/timeType/'.$timeType;
        $orderstatus && $url .= '/orderstatus/'.$orderstatus;

        return $this->request($url);

    }


    /**
     * 通过ibay订单号查询订单
     * @param $orderId string  订单号
     */
    public function getOrderDetail($orderId)
    {

        $url =  $this->url.'/GetOrderDetail';
        $url .=  '/auth/'.config("ibay.api")['code'];
        $url .=  '/orderId/'.$orderId;

        return $this->request($url);
    }


}